<?php
include_once(SYSTEM.'/ValidationRule.php');

class RegexRule extends ValidationRule 
{
	public $Pattern;
	public $String;
	
	public function __construct($pattern, $string, $message) 
	{
		$this->Pattern = $pattern;
		$this->String = $string;
		
		if(!isset($message)) 
		{
			$message = 'Chuoi k nam trong mau';	
		}
		parent::__construct($message);
	}
	
	public function Validate() 
	{
		if(!preg_match($this->Pattern, $this->String))
			return $this->Message;
		
		return 'OK';
	}
}